package com.teach.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.teach.entity.user;
import com.teach.service.UserService;
import com.teach.service.impl.UserServiceImpl;

public class UserDeleteServlet extends HttpServlet {

	private UserService userService = new UserServiceImpl();
	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		try{
			Integer userId = Integer.valueOf(request.getParameter("userId"));
			userService.deleteById(userId);
			request.setAttribute("msg", "删除用户成功");
			request.setAttribute("href","user.let");
		}catch(Exception ex){
			ex.printStackTrace();//记调试日志
			request.setAttribute("error", "删除用户失败:"+ex.getMessage());
		}
		request.getRequestDispatcher("/admin/msg.jsp").forward(request, response);
	}
}
